package com.yxuan.springboot.controller;

import com.yxuan.springboot.model.RecruitmentBrochureNoTotal;
import com.yxuan.springboot.service.RecruitmentBrochureService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import com.yxuan.springboot.model.RecruitmentBrochure;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 
 * @author zchao
 *   RecruitmentBrochure控制器
 * @date 2023-06-03 17:43:02
 */
@Controller
@Api(tags = "招生简章")
@RequestMapping(value = "/recruitmentbrochure", method = {RequestMethod.POST,RequestMethod.GET})
@CacheConfig(cacheNames = "recruitmentbrochure")//缓存名，和管理器中配置的一致
public class RecruitmentBrochureController extends BaseController<RecruitmentBrochure>{

    @Autowired
    private RecruitmentBrochureService recruitmentBrochureService;

    /**
     *  查询招生简章（部分字段）
     */
    @ApiOperation(value = "查询招生简章（部分字段）", notes = "查询招生简章（部分字段）")
    @RequestMapping("/findManyByPramasNoTotal")
    @ResponseBody
    @Cacheable(key = "'findManyByPramasNoTotal-' + #recruitmentBrochure",unless = "#result==null", condition = "#recruitmentBrochure!=null")//#result返回结果
    public List<RecruitmentBrochureNoTotal> findManyByPramasNoTotal(RecruitmentBrochure recruitmentBrochure) throws Exception {
        return recruitmentBrochureService.getManyByPramasNoTotal(recruitmentBrochure);
    }



    /**
     * 根据条件查询单个结果
     *
     */
    @ApiOperation(value = "根据条件查询单个数据", notes = "根据条件查询单个数据",httpMethod = "GET")
    @RequestMapping("/loadObjectByPramas")
    @ResponseBody
    @Cacheable(key = "'recruitmentbrochure-' + #t",
            unless = "#result==null",
            condition = "#t!=null")//#result返回结果
    public RecruitmentBrochure loadObjectByPramas(RecruitmentBrochure t){
        try {
            return recruitmentBrochureService.findObjectByPramas(t);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }


	

}
